package cn.edu.nwsuaf.teachercenter.pojo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Grade entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "grade", catalog = "exam")
public class Grade implements java.io.Serializable {

	// Fields

	private String gradeNo;
	private Major major;
	private String gradeName;
	private Set<Sclass> sclasses = new HashSet<Sclass>(0);

	// Constructors

	/** default constructor */
	public Grade() {
	}

	/** minimal constructor */
	public Grade(String gradeNo, Major major, String gradeName) {
		this.gradeNo = gradeNo;
		this.major = major;
		this.gradeName = gradeName;
	}

	/** full constructor */
	public Grade(String gradeNo, Major major, String gradeName,
			Set<Sclass> sclasses) {
		this.gradeNo = gradeNo;
		this.major = major;
		this.gradeName = gradeName;
		this.sclasses = sclasses;
	}

	// Property accessors
	@Id
	@Column(name = "grade_no", unique = true, nullable = false, length = 50)
	public String getGradeNo() {
		return this.gradeNo;
	}

	public void setGradeNo(String gradeNo) {
		this.gradeNo = gradeNo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "major_no", nullable = false)
	public Major getMajor() {
		return this.major;
	}

	public void setMajor(Major major) {
		this.major = major;
	}

	@Column(name = "grade_name", nullable = false, length = 50)
	public String getGradeName() {
		return this.gradeName;
	}

	public void setGradeName(String gradeName) {
		this.gradeName = gradeName;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "grade")
	public Set<Sclass> getSclasses() {
		return this.sclasses;
	}

	public void setSclasses(Set<Sclass> sclasses) {
		this.sclasses = sclasses;
	}

}